package com.rajeshDyadav.file.folder;

import java.io.File;

public class SearchRecursive {

    public void getFileList(File folder, String fileName) {
	File fileList[] = folder.listFiles();
	for (int i = 0; i < fileList.length; i++) {
	    if (fileList[i].isDirectory()) {
		//System.out.println("Looking inside " + fileList[i].getPath());
		//System.out.print(".");
		getFileList(fileList[i], fileName);		
	    } else if (fileList[i].isFile()) {
		if (fileList[i].getName().toLowerCase().contains(fileName)) {
		    System.out.println("\nFound at: " + fileList[i].getPath());
		}
	    }
	}
    }
    
    public void searchFile(File folder, String fileName) {
	getFileList(folder, fileName);
    }

    public static void main(String[] args) {
	SearchRecursive sr = new SearchRecursive();
	File file = new File("/raj");
	String fileName = "cxsetup";
	sr.getFileList(file, fileName);
    }
}
